package com.apes.hr.cultivate.model;

import com.alibaba.fastjson.annotation.JSONField;
import com.apes.framework.jpa.DefaultPersistListener;
import com.apes.framework.jpa.Model;
import com.apes.framework.jpa.comment.Comment;
import com.apes.framework.jpa.generator.ApesGenerator;
import com.apes.framework.util.DateUtil;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;

import javax.persistence.*;
import javax.validation.constraints.NotNull;
import java.util.Date;

/**
 * 培训课程上课时间段
 * @author Linwz
 * @create 2019-06-17 15:11
 */
@Getter
@Setter
@SelectBeforeUpdate
@DynamicInsert
@DynamicUpdate
@Entity
@EntityListeners(DefaultPersistListener.class)
@Table(name = CultivatePlanTime.CONST_TABLE_NAME)
public class CultivatePlanTime extends Model {
    public static final String CONST_TABLE_NAME = "hr_cultivate_plan_time";

    @Id
    @Column(name = "id")
    @ApesGenerator(code = CONST_TABLE_NAME, name = "上课时间段")
    @Comment("上课时间段编码")
    private String id;   //上课时间段编码

    @NotNull
    @ManyToOne(optional = false)
    @JoinColumn(name = "cultivate_plan_item_id", referencedColumnName = "ID")
    @Comment("培训计划明细")
    private CultivatePlanItem cultivatePlanItem; //培训计划明细

    @JSONField(format = DateUtil.SHOW_DATE_FORMAT)
    @Temporal(TemporalType.DATE)
    @Column(name = "course_date")
    @Comment("课程日期")
    private Date courseDate;  //课程日期

    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "course_state_time")
    @Comment("课程开始时段")
    private Date courseStateTime;  //课程开始时段 只取时分

    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "course_end_time")
    @Comment("课程结束时段")
    private Date courseEndTime;  //课程结束时段 只取时分


//    @Column(name="schedulings",length = 4000)
//    @Comment("排期方式")
//    private String schedulings;  //排期方式


}
